package com.aaa.controller;


import com.aaa.entity.PrivateMessage;
import com.aaa.service.impl.PrivateMessageServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Bean
 * @since 2021-09-05
 */
@RestController
@Api(tags = "私信")
@CrossOrigin
@RequestMapping("/private-message")
public class PrivateMessageController {

    @Autowired
    PrivateMessageServiceImpl privateMessageService;
    //添加私信
    @ApiOperation("添加私信")
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    public boolean add(@ApiParam("发送者昵称")String uname, PrivateMessage privateMessage){
        return privateMessageService.add(uname,privateMessage);
    }

    @ApiOperation("查看私信列表")
    @RequestMapping(value = "seleinform",method = RequestMethod.POST)
    public List<Map<String,Object>> seleinform(@ApiParam("用户的id") Integer uid){
        return privateMessageService.seleinform(uid);
    }

    @ApiOperation("查看私信详情信息")
    @RequestMapping(value = "seleone",method = RequestMethod.POST)
    public List<Map<String,Object>> seleone(@ApiParam("用户的id") Integer uid,@ApiParam("对方id") Integer id){
        return privateMessageService.seleone(uid,id);
    }
}
